/*
 * @Author: zhanglianchang
 * @Date: 2020-08-01 14:39:32
 * @Last Modified by: taoshiwei
 * @Last Modified time: 2019-04-29 14:56:00
 *
 * 目录
 */

import { createAPI } from '@/utils/request'

// 目录列表
export const getDir = data => createAPI('/directorys', 'get', data)

// 目录简单列表
export const getSimpleDir = data => createAPI('/directorys/simple', 'get', data)

// 目录详情
export const detailDir = data => createAPI(`/directorys/${data.id}`, 'get', data)

// 目录添加
export const addDir = data => createAPI('/directorys', 'post', data)

// 目录修改
export const updateDir = data => createAPI(`/directorys/${data.id}`, 'put', data)

// 目录删除
export const removeDir = data =>
  createAPI(`/directorys/${data}`, 'delete', data)

// 目录状态
export const changeStateDir = data => createAPI(`/directorys/${data.id}/$(data.state)`, 'post', data)
// 学科简单列表
export const simple = data => createAPI('/subjects/simple', 'get', data)

class Directory {
  // 目录列表
  list = data => createAPI('/directorys', 'get', data)

  // 目录简单列表
  simple = data => createAPI('/directorys/simple', 'get', data)

  // 目录详情
  detail = data => createAPI(`/directorys/${data.id}`, 'get', data)

  // 目录添加
  add = data => createAPI('/directorys', 'post', data)

  // 目录修改
  update = data => createAPI(`/directorys/${data.id}`, 'put', data)

  // 目录删除
  remove = data => createAPI(`/directorys/${data.id}`, 'delete', data)

  // 目录状态
  changeState = data => createAPI(`/directorys/${data.id}/${data.state}`, 'post', data)
}

export default new Directory()
